﻿package com.tudou.home.controller.ad
{
    import com.tudou.ad.consts.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.model.ad.*;
    import com.tudou.home.view.*;
    import com.tudou.home.view.ad.*;
    import com.tudou.track.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class AdCornerCommand extends SimpleCommand
    {

        public function AdCornerCommand()
        {
            return;
        }// end function

        private function sendTrack(param1:String, param2:Array = null) : void
        {
            var _loc_3:* = facade.retrieveProxy(AdProxy.NAME) as AdProxy;
            var _loc_4:* = facade.retrieveProxy(AdCornerProxy.NAME) as AdCornerProxy;
            if (_loc_3.adTracker && _loc_4.adItemInfo)
            {
                _loc_3.adTracker.adSend(_loc_4.adItemInfo, _loc_4.adThrowInfo, param1, param2);
            }
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_2:* = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            var _loc_3:* = facade.retrieveProxy(AdInfoProxy.NAME) as AdInfoProxy;
            var _loc_4:* = facade.retrieveMediator(AdCornerMediator.NAME) as AdCornerMediator;
            var _loc_5:* = facade.retrieveProxy(AdCornerProxy.NAME) as AdCornerProxy;
            switch(param1.getName())
            {
                case AdCornerCommandSet.START:
                {
                    _loc_5.adItemInfo = _loc_3.getAdItemByType(AdType.CORNER_AD);
                    _loc_5.adThrowInfo = _loc_3.throwInfo;
                    _loc_5.load(1000);
                    break;
                }
                case AdCornerCommandSet.CLEAR:
                {
                    break;
                }
                case AdCornerCommandSet.AD_SHOW:
                {
                    sendTrack(NodeLog.AD_SHOW_START);
                    break;
                }
                case AdCornerCommandSet.AD_LOADER_READY:
                {
                    _loc_4.adItemInfo = _loc_5.adItemInfo;
                    _loc_4.adThrowInfo = _loc_5.adThrowInfo;
                    _loc_4.setAdDisplay(_loc_5.primaryAd);
                    _loc_4.showAd();
                    _loc_2.addCornerAD(_loc_4.getAdDisplay());
                    break;
                }
                case AdCornerCommandSet.AD_CLICK_CORNERAD:
                {
                    sendTrack(NodeLog.AD_CLICK, [null]);
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
